<?
	if(isset($_GET['cid'])){
		$cid = intval($_GET['cid']);
	}else{$cid = 0;}
	
	if(isset($_GET['ttid'])){
		$ttid = intval($_GET['ttid']);
	}
	
	if(isset($_GET['keyword'])){
		$keyword = $_GET['keyword'];
	}
	
	if($cid == 0){
		$sql = "SELECT * FROM ".$prefix."tuyendung WHERE 1";
	}else{
		$sql = "SELECT * FROM ".$prefix."tuyendung WHERE td_loaituyendung = '".$cid."'";
	}
	$sql .= " AND td_hienthi = 1";
	
	/////////TIM KIEM THEO TINH THANH ///////////
	if(isset($ttid) && ($ttid != "") ){
		$sql .= " AND td_tinhthanh = '".$ttid."'";
	}
	
	if(isset($keyword) && ($keyword != "") ){
		$sql .= " AND (td_tieude like '%".$keyword."%' OR td_mota like '%".$keyword."%' OR td_chitiet like '%".$keyword."%')";
	}
	
	if(isset($_GET['sid'])){
		$sid = intval($_GET['sid']);
	
		if($sid == 1){
			$sql .= " AND td_trangthai = 0";
		}else if($sid == 2){
		
			$sql .= " AND td_trangthai = 1";
			
		}else if($sid == 3){
		
			$sql .= " ORDER BY td_id DESC";
			
		}else{
			$sql .= " ORDER BY td_id ASC";
		}
	}
	
	
	//Paging
	$pp=10; 
	$parr=array();
	$parr=paging($sql,$pp);
	$page=$parr[0];
	$limitvalue=$parr[1];
	$numofpages=$parr[2];
	$sql.=" LIMIT $limitvalue, $pp";
	//
	$rs = $db->query($sql);
?>

<script language="javascript">
	function funSort(id,cid,p){
		window.location = '<?=$root?>/?mod=tuyendung&cid=' + cid + '&sid=' + id + '&p=' + p;
	}
</script>
<div id="filtersDescription">
    
	<div class="corner-round-04-top-right">
        <div class="corner-round-04-top-left">
            <div class="corner-round-04-top-bg"></div>
        </div>
    </div>

	<div class="corner-round-04-body"> 
        
        <ul id="descriptionBar" style="margin:0px;">
            <li style="float:left;margin:0px;line-height:20px;">Tìm thấy <b class="highline"><?=$db->num_rows($rs)?></b> tin tuyển dụng</li>

            <li style="float:right;margin:0px;line-height:20px;" id="menuContainer">
              Sắp xếp theo:
			  <select name="sort" style="width:120px;" onchange="funSort(this.value,'<?=$cid?>','<?=$p?>');">
			 	<option value="0" <? if($sid == 0){?> selected="selected" <? }?>>--- Tất cả ---</option>
				<option value="1" <? if($sid == 1){?> selected="selected" <? }?>>Người tìm việc</option>
				<option value="2" <? if($sid == 2){?> selected="selected" <? }?>>Việc tìm người</option>
				<option value="3" <? if($sid == 3){?> selected="selected" <? }?>>Mới dần</option>
				<option value="4" <? if($sid == 4){?> selected="selected" <? }?>>Cũ dần</option>
			  </select>
			  </li>                       
        </ul>
        <br class="clearBoth" style="font-size:0pt;"/> 
        <p></p>        
                      
    </div>

    <div class="corner-round-04-bottom-right">
        <div class="corner-round-04-bottom-left">
            <div class="corner-round-04-bottom-bg"></div>
        </div>
    </div>   
</div> 

     
                         
            
<!-- Product List { -->
<div id="product-list">
    <div id="product-list-header">       
        <div class="product-col product-col-name">
            <p>Tiêu đề tuyển dụng</p>

        </div>
        <div class="product-col product-col-price">
            <p>Nơi đăng</p>
        </div>
        <div class="product-col product-col-region">
            <p>Ngày đăng</p>
        </div>
    </div>

    <div style="clear:both;height:4px;font-size:0pt;"></div>
    <div id="product-list-body">
        <div class="corner-round-05-top-right">
            <div class="corner-round-05-top-left">
                <div class="corner-round-05-top-bg"></div>
            </div>
        </div>
        <div class="corner-round-05-body2"> 
            
                <table width="100%" cellpadding="0" cellspacing="0" id="products-items">
			<?
				$st =0;
				 while($row = $db->fetch_array($rs)){
				 $st++;
				 $td_id = $row[td_id];
				 $td_loaituyendung = $row[td_loaituyendung];
				 $td_tieude = $myString->unQuote(stripslashes($row[td_tieude]));
				 $td_mota = $myString->unQuote(stripslashes($row[td_mota]));
				 $td_maso = $row[td_maso];
				 $td_anhthehien = $PathThumbFile . $row[td_anhthehien];
				 $td_mucluong = $row[td_mucluong];
				 $td_nguoidang = $row[td_nguoidang];
				 $td_nguoidang_ten = tenNguoiDung($row[td_nguoidang]);
				 $td_quocgia = layQuocGia($row[td_quocgia]);
				 $td_tinhthanh = layTinhThanh($row[td_tinhthanh]);
				 $td_ngaydang = format_date($row[td_ngaydang]);
				 $td_thoigiandang = $row[td_thoigiandang];
				 $td_nganhnghe = $myString->unQuote(stripslashes($row[td_nganhnghe]));
				 $td_loaihinhcongviec = $row[td_loaihinhcongviec];
				 $td_capbac = $row[td_capbac];
				 $td_sonamkinhnghiem = $row[td_sonamkinhnghiem];
				 $td_capbactoithieu = $row[td_capbactoithieu];
				 $td_bangcaptoithieu = $row[td_bangcaptoithieu];
				 $td_ngoaingu = $myString->unQuote(stripslashes($row[td_ngoaingu]));
				 $td_kynang = $myString->unQuote(stripslashes($row[td_kynang]));
				 $tailieuguikem = $myString->unQuote(stripslashes($row[tailieuguikem]));
				 $td_chitiet = $myString->unQuote(stripslashes($row[td_chitiet]));
				 $td_solanxem = $row[td_solanxem];
				 $td_xemgannhat = format_date_time($row[td_xemgannhat]);
				 $td_hienthi = $row[td_hienthi];
				 $td_vip = $row[td_vip];
				 
			?>
                    <tr <? if($st % 2 == 0){ ?> bgcolor="#EEEEEE" <? } ?>>
                        <td class="col-name" valign="middle">
                            <h1>
                                &nbsp;<img src="<?=$root?>/themes/images/icon/star.gif" border="0"/>&nbsp;<a href="<?=$root?>/chi-tiet-tuyen-dung/<?=$td_id?>/<?=$myString->vietdecode($td_tieude)?>" class="product-name" title="<?=$td_tieude?>"><?=$td_tieude?></a>
								
								<?
									if($td_vip == 1){
								?>
								<blink><font color="red"><b>VIP</b></font></blink>
								<? } ?>
                            </h1> 
                        </td>
                        <td class="col-price">
                            <p>
                                <?=$td_tinhthanh?>                                        
                            </p>
                        </td>
                        <td class="col-region">
                            <p>
                                <?=$td_ngaydang?>
                            </p>
                        </td>
                    </tr>  
                <? if($st != $db->num_rows($rs)){ ?>
                    <tr>
                        <td colspan="4" style="border-bottom:solid 1px #CCCCCC;height:1px;font-size:0pt;"></td>
                    </tr>                       
				<? } ?>
           <? } 
		   		if($db->num_rows($rs) == 0){
		   ?>     

 				<tr>
					<td align="left" style="padding-left:10px;">Không có tin tuyển dụng nào !</td>
				</tr>
           <? } ?>     
                </table> 
                
        </div>
        <div class="corner-round-05-bottom-right">
            <div class="corner-round-05-bottom-left">
                <div class="corner-round-05-bottom-bg"></div>

            </div>
        </div>    
    </div>
    <div id="product-list-footer"></div>
</div>

<!-- Paging { -->


<div id="paging">
    <div class="corner-round-01-top-right">
        <div class="corner-round-01-top-left">
            <div class="corner-round-01-top-bg"></div>

        </div>
    </div>
    <div class="corner-round-01-body" style="text-align:right">            
    <p align="center" class="font">
	 <?php echo page_div( "".$root."/?mod=tuyendung&sid=".$sid."&cid=".$cid."&p=%d_pg", "10", ceil ( $numofpages ), $page ); ?>
	 </p>
    </div>
    <div class="corner-round-01-bottom-right">
        <div class="corner-round-01-bottom-left">
            <div class="corner-round-01-bottom-bg"></div>
        </div>
    </div>   

</div>   

<!-- } Paging -->

<!-- } Product List -->